#![allow(non_snake_case)]

use crate::controls::install::*;
use crate::controls::restart::*;
use crate::controls::start::*;
use crate::controls::stop::*;
use crate::controls::uninstall::*;

// 安装服务
#[unsafe(no_mangle)]
#[cfg(windows)]
pub extern "system" fn Install() -> usize {
    match install_service() {
        Ok(_) => 1,
        Err(_) => 0,
    }
}

#[cfg(not(windows))]
#[unsafe(no_mangle)]
pub extern "system" fn Install() -> usize {
    panic!("此程序仅适用于Windows系统。");
}

// 卸载服务
#[unsafe(no_mangle)]
#[cfg(windows)]
pub extern "system" fn Uninstall() -> usize {
    match uninstall_service() {
        Ok(_) => 1,
        Err(_) => 0,
    }
}

#[cfg(not(windows))]
#[unsafe(no_mangle)]
pub extern "system" fn Uninstall() -> usize {
    panic!("此程序仅适用于Windows系统。");
}

// 启动服务
#[unsafe(no_mangle)]
#[cfg(windows)]
pub extern "system" fn Start() -> usize {
    match start_service() {
        Ok(_) => 1,
        Err(_) => 0,
    }
}

#[cfg(not(windows))]
#[unsafe(no_mangle)]
pub extern "system" fn Start() -> usize {
    panic!("此程序仅适用于Windows系统。");
}

// 停止服务
#[unsafe(no_mangle)]
#[cfg(windows)]
pub extern "system" fn Stop() -> usize {
    match stop_service() {
        Ok(_) => 1,
        Err(_) => 0,
    }
}

#[cfg(not(windows))]
#[unsafe(no_mangle)]
pub extern "system" fn Stop() -> usize {
    panic!("此程序仅适用于Windows系统。");
}

// 重启服务
#[unsafe(no_mangle)]
#[cfg(windows)]
pub extern "system" fn Restart() -> usize {
    match restart_service() {
        Ok(_) => 1,
        Err(_) => 0,
    }
}

#[cfg(not(windows))]
#[unsafe(no_mangle)]
pub extern "system" fn Restart() -> usize {
    panic!("此程序仅适用于Windows系统。");
}
